import React, { useRef, useState, useEffect } from 'react';
import { connect } from 'umi';
import { Drawer, Space, Button, Steps, Form } from 'antd';
import DataEntry from './components/DataEntry';
import './index.less';
const GatherEdit = (props) => {
    const { onClose, visible = {}, onOk } = props;
    const { show = false, details = [] } = visible;

    useEffect(() => {
        if (!show) {
            setData([]);
        } else {
            setData(details);
        }
    }, [show]);

    const [data, setData] = useState([]);
    const ref = useRef(null);
    return (
        <Drawer
            title="设置申请信息"
            onClose={onClose}
            open={show}
            placement={'top'}
            height={'100%'}
            extra={
                <Space>
                    <Button onClick={() => onClose()}>取消</Button>
                    <Button
                        type="primary"
                        onClick={() => {
                            onOk && onOk(ref.current.fetchData)
                        }}
                    >
                        确定
                    </Button>
                </Space >
            }
        >
            <div className="gatherEdit_box">
                <DataEntry defaultData={data} ref={ref}></DataEntry>
            </div>
        </Drawer>
    );
};
export default connect(({ loading }) => ({
    loading: loading.models.liveStreaming,
}))(GatherEdit);
